package cn.edu.sgu.www.mhxysy.controller.qiling;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.entity.except.Property;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.qiling.QilingViewAttributeService;
import cn.edu.sgu.www.mhxysy.vo.qiling.QilingViewAttributeVO;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "器灵预览属性管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@RestController
@RequestMapping(path = "/qiling_view_attribute", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class QilingViewAttributeController {

	private final QilingViewAttributeService qilingViewAttributeService;

	@Autowired
	public QilingViewAttributeController(QilingViewAttributeService qilingViewAttributeService) {
		this.qilingViewAttributeService = qilingViewAttributeService;
	}

	@ApiOperation("查询器灵的可选属性")
	@RequestMapping(value = "/selectProperty", method = RequestMethod.GET)
	public JsonResult<List<Property>> selectProperty(
			@ApiParam(name = "qilingId", value = "器灵ID", required = false)
			@RequestParam(required = false) String qilingId) {
		List<Property> list = qilingViewAttributeService.selectProperty(qilingId);

		return JsonResult.success(null, list);
	}

	@ApiOperation("查询器灵预览属性")
	@RequestMapping(value = "/selectAttributes", method = RequestMethod.GET)
	public JsonResult<List<QilingViewAttributeVO>> selectAttributes(
			@ApiParam(name = "equipmentId", value = "装备类型ID", required = false)
			@RequestParam(required = false) Integer equipmentId) {
		List<QilingViewAttributeVO> list = qilingViewAttributeService.selectAttributes(equipmentId);

		return JsonResult.success(null, list);
	}

}